﻿using UnityEngine;
using System.Collections;
using Dict.DataModel;
using ProtoBuf.Message;

namespace Room
{
    public class RCUIUnionGuard : RCUIPlayer
    {
        float dis;
        public RCUIUnionGuard(RoomCharactor owner)
            : base(owner)
        {
            this.owner = owner;
            type = UIType.UnionGuard;
            ClickRange = (float)Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.UnionFightCanClickGuardRange;
            dis = (float)Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.UnionFightArriveGuard;
        }
        

        protected override void OnClick()
        {
            var self = owner.charactorManager.GetSelfCharactor();
            var ai = self.ai as RCAIUnionSelf;
            if (ai != null && ai.IdleState() )
            {
                ai.AutoGoto(owner.transform.position, () => 
                {
                    if (ai.IdleState())
                    {
                        var net = Room.RoomManager.currentRoom.netManager as RoomNetUnionFight;

                        var _ai = owner.ai as RCAIGuard;
                        var _camp = _ai.Camp;
                        if (_camp == net.netBattle.camp)
                        {
                            var say = _ai.dictData.Say;
                            owner.ShowBubble(say);
                        }
                    }
                }, dis);
            }
        }

    }
}
